From: Richard M. Stallman Date: Tue, 15 Jun 1993 07:59:07 +0000 (+0000) Subject: (dired-repeat-over-lines): Going fwd, skip new lines X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~95323 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=cfe89c4fa50b7f7e72c0e9d3c699f00ed17025db;p=emacs.git (dired-repeat-over-lines): Going fwd, skip new lines that FUNCTION inserts after the current line. Going backwd, no need for dired-move-to-filename each time. --- diff --git a/lisp/dired.el b/lisp/dired.el index 949eaec83f6..20a3267810d 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1542,21 +1542,27 @@ Optional argument means return a file name relative to `default-directory'." (defun dired-repeat-over-lines (arg function) ;; This version skips non-file lines. - (beginning-of-line) - (while (and (> arg 0) (not (eobp))) - (setq arg (1- arg)) - (beginning-of-line) - (while (and (not (eobp)) (dired-between-files)) (forward-line 1)) - (save-excursion (funcall function)) - (forward-line 1)) - (while (and (< arg 0) (not (bobp))) - (setq arg (1+ arg)) - (forward-line -1) - (while (and (not (bobp)) (dired-between-files)) (forward-line -1)) + (let ((pos (make-marker))) (beginning-of-line) - (save-excursion (funcall function)) - (dired-move-to-filename)) - (dired-move-to-filename)) + (while (and (> arg 0) (not (eobp))) + (setq arg (1- arg)) + (beginning-of-line) + (while (and (not (eobp)) (dired-between-files)) (forward-line 1)) + (save-excursion + (forward-line 1) + (move-marker pos (1+ (point)))) + (save-excursion (funcall function)) + ;; Advance to the next line--actually, to the line that *was* next. + ;; (If FUNCTION inserted some new lines in between, skip them.) + (goto-char pos)) + (while (and (< arg 0) (not (bobp))) + (setq arg (1+ arg)) + (forward-line -1) + (while (and (not (bobp)) (dired-between-files)) (forward-line -1)) + (beginning-of-line) + (save-excursion (funcall function))) + (move-marker pos nil) + (dired-move-to-filename))) (defun dired-between-files () ;; Point must be at beginning of line